package com.itheima.api;

import java.util.Calendar;

public class CalendarTest {

    // 日历类
    public static void main(String[] args) {
        demo1();
        System.out.println("+++++++++++++++++++++++++++++");
        demo2();
        System.out.println("+++++++++++++++++++++++++++++");
        demo3();
    }


    public static void demo1() {
        Calendar instance = Calendar.getInstance();
        instance.set(Calendar.YEAR, 2022);
        int year = instance.get(Calendar.YEAR);
        int month = instance.get(Calendar.MONTH) + 1;
        int dayOfMonth = instance.get(Calendar.DAY_OF_MONTH);
        System.out.println(year + "年" + month + "月" + dayOfMonth + "日");
    }


    public static void demo2() {
        Calendar instance = Calendar.getInstance();
        instance.add(Calendar.YEAR, -1);
        instance.add(Calendar.MONTH, -2);
        instance.add(Calendar.DAY_OF_MONTH, -3);
        System.out.println(instance.get(Calendar.YEAR));
        System.out.println(instance.get(Calendar.MONTH));
        System.out.println(instance.get(Calendar.DAY_OF_MONTH));
    }


    public static void demo3() {
        Calendar instance = Calendar.getInstance();
        System.out.println(instance.getTime());
        System.out.println(instance.getTimeInMillis());
        System.out.println(instance.getTimeZone());
    }
}
